package board.action;


import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

 public class Hot_Girl_BoardFrontController extends HttpServlet implements Servlet {
	 
	 protected void doGet(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException {
		doProcess(request,response);
	}  	
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException {
		doProcess(request,response);
	}  
	
	 protected void doProcess(HttpServletRequest request, HttpServletResponse response) 
	 	throws ServletException, IOException {
		 String RequestURI=request.getRequestURI();
		 String contextPath=request.getContextPath();
		 String command=RequestURI.substring(contextPath.length());
		 
		 System.out.println("RequestURI==="+RequestURI);
		 System.out.println("contextPath==="+contextPath);
		 System.out.println("command==="+command);
		 Hot_Girl_ActionForward forward=null;
		 Hot_Girl_Action action=null;
		 System.out.println("마지막 점검1");
		 
		 if(command.equals("/board/BoardWrite.do")){
			   forward=new Hot_Girl_ActionForward();
			   forward.setRedirect(false);
			   forward.setPath("../board/hot_girl_write.jsp");
			  
		}else if(command.equals("/board/BoardDelete.do")){
			   forward=new Hot_Girl_ActionForward();
			   forward.setRedirect(false);
			   forward.setPath("../board/hot_girl_delete.jsp");
			   
		}else if(command.equals("/board/admin/manager_delete.do")){
			   forward=new Hot_Girl_ActionForward();
			   forward.setRedirect(false);
			   forward.setPath("../admin/manager_hot_girl-delete.jsp");
			
	 	}else if(command.equals("/board/BoardAddAction.do")){
			   action  = new Hot_Girl_BoardAddAction();
			   try {
				   forward=action.execute(request, response );
			   } catch (Exception e) {
				   e.printStackTrace();
			   }
		
			
		   
		   }else if(command.equals("/board/BoardHotGirl.do")){
			   action = new Hot_Girl_BoardCounts();
			   try{
				   forward=action.execute(request, response);
			   }catch(Exception e){
				   e.printStackTrace();
			   }
			   System.out.println("koo");
		   }else if(command.equals("/board/BoardList.do")){
			   action = new Hot_Girl_BoardListAction();
			   try{
				   forward=action.execute(request, response);
			   }catch(Exception e){
				   e.printStackTrace();
			   }
			   System.out.println("koo");
		   }else if(command.equals("/board/admin/manager_hot-girl.do")){
			   action = new manager_Hot_Girl_BoardListAction();
			   try{
				   forward=action.execute(request, response);
			   }catch(Exception e){
				   e.printStackTrace();
			   }
		   }else if(command.equals("/board/admin/manger_BoardDetailAction.do")){
			   System.out.println("마지막점검3");
			   action = new manager_Hot_Girl_BoardDetailAction();
			   System.out.println("마지막점검4");
			   try{
				   forward=action.execute(request, response);
			   }catch(Exception e){
				   e.printStackTrace();
			   }
		   }else if(command.equals("/board/admin/manager_hot_girl-delete.do")){
			   action = new manager_Hot_girl_BoardDeleteAction();
			   try{
				   forward=action.execute(request, response);
			   }catch(Exception e){
				   e.printStackTrace();
			   }
		   }else if(command.equals("/board/DetailAction.do")){
			   System.out.println("마지막점검3");
			   action = new Hot_Girl_BoardDetailAction();
			   System.out.println("마지막점검4");
			   try{
				   forward=action.execute(request, response);
			   }catch(Exception e){
				   e.printStackTrace();
			   }
		   }
		   if(forward.isRedirect()){
			   response.sendRedirect(forward.getPath());
		   }else{
			   RequestDispatcher dispatcher=
				   request.getRequestDispatcher(forward.getPath());
			   dispatcher.forward(request, response);
		   }
	 }
}